{{- $script := resources.Get "scripts/index.js" | resources.Minify -}}
{{- $serviceWorker := resources.Get "service-worker.js" -}}

<!-- Site Footer -->
<footer class="site-footer">
  <p>© {{ if eq now.Year 2017 }}2017{{ else }}2017-{{ now.Year }}{{ end }} {{ .Site.Title }}</p>
  <p>Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> with theme <a href="https://github.com/laozhu/hugo-nuo" target="_blank" rel="noopener">Nuo</a>.</p>
  {{ if and (isset .Site.Params "icp") (ne .Site.Params.ICP "") }}
    <p><a href="http://www.miitbeian.gov.cn" title="Check ICP info" target="_blank" rel="noopener">{{ .Site.Params.ICP }}</a></p>
  {{ end }}
</footer>

<!-- Smooth Scroll -->
<script src="https://cdn.jsdelivr.net/npm/smooth-scroll@15.0.0/dist/smooth-scroll.min.js"></script>

<!-- Video.js for post -->
{{ if and (eq .Kind "page") (eq .Type "post") }}
<script async src="https://cdn.jsdelivr.net/npm/video.js@7.3.0/dist/video.min.js"></script>
{{ end }}

<!-- Mathjax for post -->
{{ if and (eq .Kind "page") (eq .Type "post") }}
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [['$','$'], ['\\(','\\)']],
      displayMath: [['$$','$$'], ['\\[','\\]']],
      processEscapes: true,
      processEnvironments: true,
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
      TeX: { equationNumbers: { autoNumber: "AMS" },
      extensions: ["AMSmath.js", "AMSsymbols.js"] }
    },
  });
</script>
<script type="text/x-mathjax-config">
  // Fix <code> tags after MathJax finishes running. This is a
  // hack to overcome a shortcoming of Markdown. Discussion at
  // https://github.com/mojombo/jekyll/issues/199
  MathJax.Hub.Queue(() => {
    MathJax.Hub.getAllJax().map(v => v.SourceElement().parentNode.className += ' has-jax');
  });
</script>
{{ end }}

<!-- Main Scripts -->
<script src="{{ $script.RelPermalink }}"></script>

<script>
  if ('serviceWorker' in navigator) {
    navigator.serviceWorker.register('{{ $serviceWorker.RelPermalink }}').then(function() {
      console.log('[ServiceWorker] Registered');
    });
  }
</script>

<!-- Google Analytics -->
{{ if .Site.GoogleAnalytics }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}

<!-- Baidu Tongji -->
{{ with .Site.Params.baidutongji }}
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?{{ . }}";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>
{{ end }}
